package com.yvon.grpc.client.propreties;

import io.grpc.ManagedChannel;
import io.grpc.ManagedChannelBuilder;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

/**
 * @author : wangyufeng
 * @since : 2021-10-19
 */
@Data
@Component
@ConfigurationProperties(prefix = "yvon.grpc", ignoreInvalidFields = true)
public class GrpcProperties {

    private String host;

    private int port;

    @Bean
    public ManagedChannel managedChannel() {
        return ManagedChannelBuilder.forAddress(host, port).usePlaintext().build();
    }

}
